<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="aviso" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{avisoHome.managed ? 'Edit' : 'Add'} Aviso</f:facet>




            <s:decorate id="dataCriacaoField" template="layout/edit.xhtml">
                <ui:define name="label">Data criacao</ui:define>
                <h:inputText id="dataCriacao"
                          value="#{avisoHome.instance.dataCriacao}">
                    <a:support event="onblur" reRender="dataCriacaoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="dataExpiracaoField" template="layout/edit.xhtml">
                <ui:define name="label">Data expiracao</ui:define>
                <h:inputText id="dataExpiracao"
                          value="#{avisoHome.instance.dataExpiracao}">
                    <a:support event="onblur" reRender="dataExpiracaoField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="textoField" template="layout/edit.xhtml">
                <ui:define name="label">Texto</ui:define>
                <h:inputTextarea id="texto"
                               cols="80"
                               rows="3"
                              value="#{avisoHome.instance.texto}"/>
            </s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{avisoHome.persist}"
                       disabled="#{!avisoHome.wired}"
                       rendered="#{!avisoHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{avisoHome.update}"
                       rendered="#{avisoHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{avisoHome.remove}"
                      immediate="true"
                       rendered="#{avisoHome.managed}"/>

            <s:button id="done"
                   value="Done"
             propagation="end"
                    view="/Aviso.xhtml"
                rendered="#{avisoHome.managed}"/>

            <s:button id="cancel"
                   value="Cancel"
             propagation="end"
                    view="/#{empty avisoFrom ? 'AvisoList' : avisoFrom}.xhtml"
                rendered="#{!avisoHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Criador">
    <div class="association" id="criadorParent">

        <h:outputText value="There is no criador associated with this aviso."
                   rendered="#{avisoHome.instance.criador == null}"/>

        <rich:dataTable var="_usuario"
                   value="#{avisoHome.instance.criador}"
                rendered="#{avisoHome.instance.criador != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="criadorTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_usuario.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Login</f:facet>
                <h:outputText value="#{_usuario.login}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Tipo</f:facet>
                <h:outputText value="#{_usuario.tipo}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button value="#{avisoHome.instance.criador != null ? 'Change' : 'Select'} criador"
                       view="/UsuarioList.xhtml">
                <f:param name="from" value="AvisoEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
